<?php
header('Content-type: text/vnd.wap.wml');
echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
?>
<!DOCTYPE wml PUBLIC "-//PHONE.COM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card title="Kien's wap">
<?php
	define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
	require_once("magpierss/rss_fetch.inc");
	$url   = $_GET['url'];
	$start = $_GET['start'] ? $_GET['start'] : 0;
	if(!$url)
		$url = "http://www.dientuvienthong.net/diendan/feed.php?f=88";
	else
		$url = urldecode($url);
	$rss = fetch_rss($url);
	echo  "<p>" . "Channel Title: " . $rss->channel['title'] . '<br />';
	define('MAX_LINK',5);
	foreach ($rss->items as $id=>$item) {
		if($id >= $start)
		{
			if($id >= ($start + MAX_LINK)) break;
			$href = $item['link_'];
			$title = $item['title'];
//			$content = $item['atom_content'];
			echo ($id+1)."<a href=\"viewitem.php?url=".urlencode($url)."&id=$id&page=0\">$title</a><br />\n";
		}
	}
	$linkcount = count($rss->items);
	if(($start+MAX_LINK)<$linkcount)
		echo '<a href="./showtitle.php?url='.urlencode($url).'&start='.($start+MAX_LINK).'">next</a><br />';
	if(($start-MAX_LINK)>=0)
		echo '<a href="./showtitle.php?url='.urlencode($url).'&start='.($start-MAX_LINK).'">prev</a><br />';
	echo '<a href="./">back to feed select</a>';
	echo "</p>";
?>
</card>
</wml>
